<?php
/**
 * 把email转换成邮箱的登录地址
 *
 * @param  $email
 */
function emial_to_url($email){
	if(!regex($email,'email'))return ;
	$email_postfix = explode('@',$email);
	$email_postfix = $email_postfix[1];
	C(array('email' => include('Conf/email.php')));
	$email_rule = C('email.email_rule');
	if(!empty($email_rule[$email_postfix]))return $email_rule[$email_postfix];
	return 'http://mail.'.$email_postfix;
}
function regex($value,$rule) {
	$validate = array(
	'require'=> '/.+/',
	'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',
	'url' => '/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/',
	'currency' => '/^\d+(\.\d+)?$/',
	'number' => '/\d+$/',
	'zip' => '/^[1-9]\d{5}$/',
	'integer' => '/^[-\+]?\d+$/',
	'double' => '/^[-\+]?\d+(\.\d+)?$/',
	'english' => '/^[A-Za-z]+$/',
	);
	// 检查是否有内置的正则表达式
	if(isset($validate[strtolower($rule)]))
		$rule   =   $validate[strtolower($rule)];
	return preg_match($rule,$value)===1;
}


?>